const arr = [24, 29, 19, 47, 78, 99, 71, 47];

const qsort = (src, start, end) => {
  if (start < end) {
    let key = src[start];
    let i = start;
    let j = end;
    while (i < j) {
      while (i < j && src[j] > key) {
        j--;
      }
      if (i < j) {
        src[i] = src[j];
        i++;
      }

      while (i < j && src[i] < key) {
        i++;
      }
      if (i < j) {
        src[j] = src[i];
        j--;
      }

      src[i] = key;
      qsort(src, start, i - 1);
      qsort(src, i + 1, end);
    }
  }
};

qsort(arr, 0, arr.length - 1);
console.log(arr);
